// src/store/app.ts
import { defineStore } from "pinia";

export const useAppStore = defineStore({
  id: "app",
  state: () => {
    return {
      token: '',
      name:'张三'
    };
  },
  actions: {
    setData(data: string | object) {
      console.log(data);
    },
  },
  getters: {
    fullName: (state) => {
      return state.name + '丰'
    }
  },
  // 开启数据缓存 默认存储在 sessionStorage
  persist: {
    enabled: true,
    strategies: [
      {
        // 如果不写这个 默认缓存全部
        paths: ["token",],
      },
    ],
  },
  // persist: {
  //   enabled: true,
  //   strategies: [
  //     {
  //       key: 'my_user',
  //       storage: localStorage,
  //     }
  //   ]
  // }
});
